import { MidwayConfig } from "@midwayjs/core";
// import { uploadWhiteList } from "@midwayjs/upload";
import * as path from "path";

export default {
  // use for cookie sign key, should change to your own and keep security
  keys: "1688541968172_2480",
  koa: {
    // key: keyPath,
    // cert: certPath,
    port: 7001
  },
  jwt: {
    secret: "babylon",
    expiresIn: "2d"
  },
  typeorm: {
    dataSource: {
      default: {
        type: "mysql",
        host: "49.232.246.61",
        port: 12306,
        // username: "bblwx_zq_test",
        // password: "PjCR8fSKTrXbnjjs",
        // database: "bblwx_zq_test",
        username: "bblwx_zq_dep",
        password: "mWBp72PBtHtXGij2",
        database: "bblwx_zq_dep",
        synchronize: false, // 如果第一次使用，不存在表，有同步的需求可以写 true，注意会丢数据
        logging: false,
        entities: ["**/entity/*.entity{.ts,.js}"]
      }
    }
  },
  upload: {
    // mode: UploadMode, 默认为file，即上传到服务器临时目录，可以配置为 stream
    mode: "file",
    // fileSize: string, 最大上传文件大小，默认为 10mb
    fileSize: "1024mb",
    whitelist: null, //文件扩展名白名单
    // tmpdir: string，上传的文件临时存储路径
    tmpdir: path.resolve(process.cwd(), "tmp"),

    // cleanTimeout: number，上传的文件在临时目录中多久之后自动删除，默认为 5 分钟
    cleanTimeout: 5 * 60 * 1000,
    // base64: boolean，设置原始body是否是base64格式，默认为false，一般用于腾讯云的兼容
    base64: false,
    // 仅在匹配路径到 /api/upload 的时候去解析 body 中的文件信息
    match:
      /((\/auth-api\/)|(\/app-api\/)att\/(single|multiple)-upload)|(\/auth-api\/record\/upload)|(\/cos\/)/
    // match: /\/upload/
  },
  staticFile: {
    dirs: {
      default: {
        prefix: "/",
        dir: "public",
        dynamic: true
      },
      tmp: {
        prefix: "/tmp",
        dir: "tmp"
      },
      assets: {
        prefix: "/assets",
        dir: "uploads"
      },
      template: {
        prefix: "/template",
        dir: "template"
      }
    }
  },
  cors: {
    origin: "*"
  },
  jwtCookieKey: "BABYLON-TOKEN",
  // 腾讯云cos配置
  cosv5: {
    app_id: "1329058988",
    secret_id: "AKIDJSqDRRDmARAi3C8qLdjbP4Xm5c1C9tPh",
    secret_key: "B9ta5TfdOwGQMguvjNq9HFzWpvoUxCE8",
    bucket: "bbl-1329058988",
    region: "ap-beijing",
    base_url: "https://bbl-1329058988.cos.ap-beijing.myqcloud.com",
    dir_root: "bblyz/"
  },
  prize: {
    TOTAL_CODES_TO_GENERATE: 10
  },
  // 微信小程序配置
  wxapp: {
    appid: "wx4d786d7b9ffd795c",
    secret: "964d117737cfd717324db48a45b2290d",
    grant_type: "client_credential",
    access_token_url: "https://api.weixin.qq.com/cgi-bin/token",
    access_token_cache_key: "wxapp_access_token",
    qrcode_url: "https://api.weixin.qq.com/wxa/getwxacodeunlimit",
    reward_page_path: "package/home/prize",
    env_version: "develop",
    is_hyaline: false,
    check_path: false
  },
  cache: {
    store: "memory"
  },
  wapis: [
    "/auth/",
    "/common-api/",
    "/bbl",
    "/tmp/",
    "/assets/",
    "/template/",
    "/app-api/"
  ] // 接口白名单，免jwt验证
} as MidwayConfig;
